package com.clps.learning.service.impl;


import com.clps.learning.pojo.BaseUser;
import com.clps.learning.service.LoginService;
import com.clps.learning.utils.FileUtil;


/**
 * @Program: clps-learning
 * @Description:
 * @author: Cooper
 * @date: 2021.10.12
 * @Version: 1.0
 */
public class LoginServiceImpl implements LoginService {

    @Override
    public Boolean login(BaseUser baseUser) {
        // 从txt文件里读取user对象
        BaseUser localBaseUser = FileUtil.read(baseUser.getUsername());
        // 判断user是否为空，判断用户名密码是否一致
        if(localBaseUser !=null){
            if(baseUser.getUsername().equals(localBaseUser.getUsername()) && baseUser.getPassword().equals(localBaseUser.getPassword()) && baseUser.getRole().equals(localBaseUser.getRole())){
                return true;
            }
        }
        return false;
    }
}
